<script>
    var token = "{{$token}}";
    var http_referer = "{{$http_referer}}";
    http_referer = escape2Html(http_referer);
    window.localStorage.setItem('token', token);
    window.location.href = http_referer;

    function escape2Html(str) {
        var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
        return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
    }
</script>